<template>
  <wxlogin :appid="APP_ID" :redirect_uri="REDIRECT_URI" :scope="SCOPE" :style="STYLE"></wxlogin>
</template>

<script>

import wxlogin from 'vue-wxlogin'
export default {
  components: {
    wxlogin
  },
  data() {
    return {
      // APP_ID: 'wxaf32f3359d07b0e2',
      // REDIRECT_URI: 'https://fygo.zjich.cn',
      APP_ID: 'wxd99431bbff8305a0',
      REDIRECT_URI: 'http://www.pinzhi365.com/wxlogin',
      SCOPE: 'snsapi_login',
      STYLE: '',
      state: ''
    }
  },
  mounted() {
    // http://192.168.2.186:8083/#/wxLogin
    // this.wxlogin()
  },
  methods: {
    getState() {
      let state = parseInt(Math.random() * Date.now())
      // 将state写入storage，供后续比对
      sessionStorage.setItem('wxlogin_state', state)
      return state
    },
    wxlogin(){
      // let redirect_uri = encodeURI('https://fygo.zjich.cn')
      // let appid = "wxaf32f3359d07b0e2";
      let redirect_uri = encodeURI('https://jsc.wzfeiyi.cn/fygo')
      let appid = "wx77dec9047c8c94d9";
      // let wx_url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`;
      let wx_url = `https://open.weixin.qq.com/connect/qrconnect?appid=${appid}&redirect_uri=${redirect_uri}&response_type=code&scope=SCOPE&state=STATE#wechat_redirect`
      window.location.href = wx_url
    }
  }
}
</script>